﻿using NUnit.Framework;
using Migrations.Core;

namespace Migrations.Tests
{
	[TestFixture]
	public class VersionComparerFixture
	{
		[Test]
		public void JustInitialize()
		{
			var comparer = new VersionComparer(new AppVersion(1));
			comparer.CompareWith(new DbVersion(1));
			Assert.IsFalse(comparer.ChangesPending(), "Should not yield pending changes");
		}

		[Test]
		public void ShouldReportChangesBecauseDifferentVersions()
		{
			var comparer = new VersionComparer(new AppVersion(2));
			comparer.CompareWith(new DbVersion(1));
			Assert.IsTrue(comparer.ChangesPending(), "Should yield pending changes");
		}

		[Test]
		public void ShouldReportZeroMigrationScripts()
		{
			var comparer = new VersionComparer(new AppVersion(1));
			comparer.CompareWith(new DbVersion(1));
			Assert.AreEqual(0, comparer.MigrationScripts.Count);
		}

		[Test]
		public void ShouldReportThreeMigrationScripts()
		{
			var comparer = new VersionComparer(new AppVersion(4));
			comparer.CompareWith(new DbVersion(1));
			Assert.AreEqual(3, comparer.MigrationScripts.Count);
		}
	}
}
